<%--
  Created by IntelliJ IDEA.
  User: THINKAPD
  Date: 2023/2/21
  Time: 18:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script type="text/javascript" src="/resources/jquery-3.2.1.js"></script>

</head>
<body>

<form action="add" method="post" id="form">
   邮箱:<input type="text" name="mail" id="mail"><br>
    域名0:<input type="text" name="domainNames"><br>
   <span id="mySpan"></span>


    <button type="button"  onclick="tj()">提交</button>
    <button type="button" onclick="addLine()">新增域名</button>
</form>

</body>
<script>
    $("#mail").blur(function(){

        var email = $("#mail").val();
        var flag = false;
        var message = "";
        var myreg = /^([\.a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;
        if(email =='') {
            alert("邮箱不能为空！");
            return;
        }else{
           let b= myreg.test(email);
           if(!b){
               alert("邮箱格式不对！");
               return;
           }


        }});

    function  addLine(){
        $("#mySpan").append(`<span>域名0:<input type="text" name="domainNames"><button type="button" onclick="delLine(this)">删除</button><br></span>`)
    }

    function delLine(obj){
        $(obj).parent().remove()
    }
    function tj(){
     let names=   $("[name='domainNames']").val();
       if(names.length==0){
           alert("至少输入一个域名");
           return ;
       }
       $("#form").submit();
    }
</script>
</html>
